<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>rest参数</title>
</head>

<body>
    <script>
        //ES6 引入rest参数，用于函数的实参，用来代替argument
        //ES5 获取参数的方式
        function date(){
            console.log(arguments);
        }
        date('白芷','阿娇','思慧');
        function add() {
            if (arguments.length == 1) {
                return arguments[0] + 10;
            } else if (arguments.length == 2) {
                return arguments[0] + arguments[1];
            }
        }
        console.log(add(10));
        console.log(add(10, 20));
        //rest 参数
        function date1(...args){
            console.log(args);
        }
        date1('阿娇','白芷','思慧')
    </script>
</body>

</html>